package com.beifu.manager.controller;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.log4j.Logger;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.http.MediaType;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

import com.beifu.manager.dao.AssetTypeMapper;
import com.beifu.manager.dao.VenderMapper;
import com.beifu.manager.model.AssetInfoExample;
import com.beifu.manager.model.AssetInfoExample.Criteria;
import com.beifu.manager.service.assetin.AssetInService;
import com.beifu.manager.service.assetinfo.AssetInfoService;
import com.mds.manager.utils.ResponseHelp;
import com.utils.PageUtils;

/**
 * 
* Title: AssetInfoController
* Description:资产信息
* @author    BaiBing
* @date      2018年7月11日
 */
@Controller
public class AssetInfoController {
	
	private Logger Log = Logger.getLogger(this.getClass());
	
	@Autowired
	private AssetInService assetInService;
	@Autowired
	private AssetTypeMapper assetTypeMapper;
	@Autowired
	private VenderMapper venderMapper;
	
	@Autowired
	private AssetInfoService assetInfoService;
	
	@RequestMapping("/assetinfo/goAssetInfoIndex")
	public String goOrganizationIndex(Model model, HttpServletRequest request){
		Log.info(">> 资产信息列表界面");
		
		return "/assetinfo/assetinfo_index";
	}
	
	
	/**
	 * 资产入库列表数据
	 * @param model
	 * @return
	 */
	@ResponseBody
	@RequestMapping(value="/assetinfo/getAssetInfoPage",produces=MediaType.APPLICATION_JSON_VALUE+";charset=utf-8")
	public String getPageData(Model model,HttpServletRequest request, HttpServletResponse res){
		String page = request.getParameter("pageNumber");
		String query_assetinfoid = request.getParameter("query_assetinfoid");//备品单编号
		String query_assetinfostatus = request.getParameter("query_assetinfostatus");//备品单状态
		

		AssetInfoExample example = new AssetInfoExample();
		Criteria criteria = example.createCriteria();
		if(!StringUtils.isEmpty(query_assetinfoid)){
			criteria.andIdEqualTo(Long.valueOf(query_assetinfoid));
		}
		if(!StringUtils.isEmpty(query_assetinfostatus)){
			criteria.andIsScrapEqualTo(query_assetinfostatus);
		}
		
		PageUtils Page = new PageUtils(page);
		Page.setQueryParames(example);
		Page = assetInfoService.getAssetInfoPage(Page);
		return ResponseHelp.responseText(Page);
		
	}
	
	
}
